import unittest
from classonline_course_2018.Day1 import CalTest


class TestDemo01(unittest.TestCase):
    def test01(self):
        print('This is test01.')

    def test02(self):
        print('This is test02.')

    def test03(self):
        print('This is test03.')

    def test04(self):
        print('This is test04.')

    def test05(self):
        print('This is test05.')


if __name__ == '__main__':
    suite = unittest.TestSuite()
    # 加载类
    testcase01 = unittest.TestLoader().loadTestsFromTestCase(TestDemo01)
    # 加载模块
    testcase02 = unittest.TestLoader().loadTestsFromModule(CalTest)
    # 加载TestDemo01中的测试方法test05
    testcase03 = unittest.TestLoader().loadTestsFromName('TestLoaderDemo.TestDemo01.test05')
    # 注意:参数必须是可迭代的数据类型
    testcase04 = unittest.TestLoader().loadTestsFromNames(
        ('Day1.TestLoaderDemo.TestDemo01.test01', 'Day1.TestLoaderDemo.TestDemo01.test02'))

    # suite.addTest(testcase01)
    suite.addTest(testcase02)
    suite.addTest(testcase03)
    # suite.addTest(testcase04)
    r = unittest.TestResult()
    suite.run(result=r)
    print(r.__dict__)
